#ifndef F_CASensorUniC_h
#define F_CASensorUniC_h

// ***********************************************************************

// class EDROOMTopContext

// ***********************************************************************



class EDROOMTopContext {

protected:

enum EDROOMCASensorUniSignal { EDROOMSignalTimeout, EDROOMSignalDestroy, SDataFrame };


	friend class CASensorUni;

	CASensorUni &EDROOMcomponent;

	CEDROOMMessage * &Msg;

	CEDROOMMessage * &MsgBack;

	//Ports

	CEDROOMInterface & Ssi;
	CEDROOMTimingInterface & Timer;

	enum edroomStateId{I, Ready};

	enum IdTrans{Init, SendFrame,  EDROOMMEMORIA };

	//Constantes



	//Variables

	FrameTypeReceived_t &VFrameType;
	int &VMessageNumber;


	//Pool

	class CEDROOMPOOLCDFrame:public CEDROOMProtectedMemoryPool {
		public:
		CEDROOMPOOLCDFrame(TEDROOMUInt32 elemCount,CDFrame *pMem, bool_t *pMarks);
		CDFrame	* AllocData();
	};
	CEDROOMPOOLCDFrame	& CEDROOMPoolCDFrame;


	// CONSTRUCTORES

	EDROOMTopContext (CASensorUni &act, FrameTypeReceived_t & EDROOMpVarVFrameType, int & EDROOMpVarVMessageNumber, CEDROOMPOOLCDFrame & EDROOMpPoolCDFrame );

	EDROOMTopContext ( EDROOMTopContext &contex );

public:

	bool EDROOMSearchContextTrans(TEDROOMTransId &edroomCurrentTrans);

	void EDROOMNuevoMens () { EDROOMcomponent.EDROOMNewMsg(); }

	// Funciones Definidas por el usuario

	bool_t	FGetFrames(TEDROOMInt32 num,byte_t *message);

	void	FIntToChar(TEDROOMInt32 num,byte_t * cConvert);

	void	FSendFrame();

	void	FTimeSend();

};

// ***********************************************************************

// class EDROOMTopState

// ***********************************************************************



class EDROOMTopState : public EDROOMTopContext {

protected:



	EDROOMTopContext::edroomStateId edroomCurrentState;

	EDROOMTopContext::edroomStateId edroomNextState;

	//Variables

	FrameTypeReceived_t VFrameType;
	int VMessageNumber;


	//Pools

	CEDROOMPOOLCDFrame	CEDROOMPoolCDFrame;


public:

	// CONSTRUCTOR

	EDROOMTopState (CASensorUni &act, CEDROOMMemory *pEDROOMMemory  );


	// EDROOMBehaviour**********************************************

	void EDROOMBehaviour();

	// Inicio**********************************************

	void EDROOMInicio();

	// ***********************************************************************

	// SubEstado Inicial 

	// ***********************************************************************



	TEDROOMTransId EDROOMIllegada();

	// ***********************************************************************

	// SubEstado Hoja Ready

	// ***********************************************************************



	TEDROOMTransId EDROOMReadyllegada();

};


#endif
